﻿@model KPIS.GERP.Models.ICM.RequestParcel
@using KPIS.GERP.Models.ICM
@using System.Globalization

@{ 
    int EmpId = KPIS.GERP.WEB.GIMS.Class.GimsMembership.CurrentEmpId;

    var service = new KPIS.GERP.WEB.GIMS.RequestParcelService.RequestParcelServiceClient();
    var serviceEmp = new KPIS.GERP.WEB.GIMS.EmployeeService.EmployeeServiceClient();
    var modelEmp = serviceEmp.Select(new Employee() { EmpId = EmpId }, new[] { "JobSite" }, null).FirstOrDefault();
    var JobSiteName = modelEmp.JobSite.Name;
    var EmpName = modelEmp.FullName;
    
    @*string year = DateTime.Now.ToString("yy");
    var month = DateTime.Now.Month;
    var LastPK = service.SelectRequestParcel(new KPIS.GERP.Models.ICM.RequestParcel { RecordStatus = "!D" }, null).OrderByDescending(x => x.ReqParcelId).FirstOrDefault();
    int number = Convert.ToInt32(LastPK == null ? 0 : LastPK.ReqParcelId) + 1;
    var reqcode = KPIS.GERP.Models.Class.CodeGenerate.GetNextCode(CodeGenerate.TransectionType.PrePurchaseRequest, "");jobsite + "-" + year + "-" + month + "/" + "000" + number.ToString();*@
}

@*@Html.Hidden("code", reqcode)*@


<div class="widget-box span9">        
    <div class="widget-header header-color-blue2">
        <h4 class="smaller">รายการเบิกพัสดุ</h4>
    </div>
    
    <div class="widget-body">
        <div class="widget-main">
            <div class="control-group">
                <div class="control-label">
                    @Html.LabelFor(model => model.CreatedWhen)
                </div>
                <div class="controls">
                    @Html.EditorFor(m => m.CreatedWhen, new { id="CreatedWhen", @class = "date-picker" })         
                </div>
            </div>

            <div class="control-group">
                <div class="control-label">
                    @Html.LabelFor(model => model.IcmReqCode)
                </div>
                <div class="controls">
                    @Html.TextBoxFor(model => model.IcmReqCode, new { id="txtReqCode", @readonly="readonly" })  
                    @Html.ValidationMessageFor(model => model.IcmReqCode)
                </div>
            </div>
                
            <div class="control-group">
                <div class="control-label">
                    @Html.LabelFor(model => model.RequestName)
                </div>
                <div class="controls"> 
                    @Html.EditorFor(m => m.RequestName)               
                    @Html.ValidationMessageFor(model => model.RequestName)
                </div>
            </div>

            <div class="control-group">
                <div class="control-label">
                    @Html.LabelFor(model => model.Remarks)
                </div>
                <div class="controls">
                    @Html.TextAreaFor(model => model.Remarks)
                </div>
            </div>

            <div class="control-group">
                <div class="control-label">
                    @Html.LabelFor(model => model.JobSiteId)
                </div>
                <div class="controls">
                    @Html.TextBox("JobsiteName", JobSiteName, new {  @readonly = "readonly" })
                </div>
            </div>
            
            <div class="control-group">
                <div class="control-label">
                    @Html.LabelFor(model => model.ProjectId)
                </div>
                <div class="controls">
                    @if (ViewBag.State == "Edit")
                    {
                        @Html.TextBoxFor(m => m.Project.Name, new { @readonly="readonly" })
                    }
                    else
                    {
                        @Html.DropDownListFor(m => m.ProjectId, new KPIS.GERP.WEB.GIMS.RequestParcelService.RequestParcelServiceClient().GetProject(EmpId), new { @class = "chzn-select input-xlarge" })
                        @Html.ValidationMessageFor(model => model.ProjectId)
                    }
                </div>
            </div>

            <div class="control-group">
                <div class="control-label">
                    @Html.LabelFor(model => model.WarehousePermitId)
                </div>
                <div class="controls">
                    @if (ViewBag.State == "Edit")
                    {
                        @Html.TextBoxFor(m => m.WarehousePermit.Warehouse.Name, new { @readonly="readonly"})
                    }
                    else
                    {
                        @Html.DropDownListFor(m => m.WarehousePermitId, new KPIS.GERP.WEB.GIMS.RequestParcelService.RequestParcelServiceClient().GetWarehouse(EmpId), new { @class = "chzn-select input-xlarge" })
                        @Html.ValidationMessageFor(model => model.WarehousePermitId)
                    }
                </div>
            </div>
                
            <div class="control-group">
                <div class="control-label">
                    @Html.LabelFor(model => model.WantedDate)
                </div>
                <div class="controls">
                    @Html.EditorFor(model => model.WantedDate) <text style="color:red;">@ViewBag.Message</text>           
                </div>
            </div>

            <div class="control-group">
                <div class="control-label">
                    @Html.LabelFor(model => model.RequestBy)
                </div>
                <div class="controls-detail">
                    @Html.HiddenFor(m => m.RequestBy)
                    @EmpName
                    @*@Html.DropDownListFor(m => m.RequestBy, new KPIS.GERP.WEB.GIMS.RequestParcelService.RequestParcelServiceClient().GetRequestBy(EmpId))
                    @Html.ValidationMessageFor(model => model.RequestBy)*@
                </div>
            </div>

        </div>  
    </div>


</div>    
